﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BurnSystems.Gpx
{
    /// <summary>
    /// An ordered sequence of points. (for polygons or polylines, e.g.) 
    /// </summary>
    public class GpxPointSegment
    {
        /// <summary>
        /// Stores the node
        /// </summary>
        protected XElement node;

        /// <summary>
        /// Initializes a new instance of the GpxTrack class.
        /// </summary>
        /// <param name="node">Node to be used for track</param>
        public GpxPointSegment(XElement node)
        {            
            this.node = node;
        }

        /// <summary>
        /// Gets the list of points
        /// </summary>
        public IList<GpxPoint> Points
        {
            get
            {
                return this.node
                    .Elements(GpxDocument.FullyQualifiedNS + "pt")
                    .Select(x => new GpxPoint(x))
                    .ToList()
                    .AsReadOnly();
            }
        }
    }
}
